package core.reports;

import java.io.IOException;

/**
 * This is the interface for all report builders.  All concrete classes build a table for use in
 * printing reports, but may represent their data different ways.  See the documentation for each
 * concrete class for more information.
 * @author Royce
 *
 */
public interface IReportBuilder {

	/**
	 * Opens a file with the given fileName to write to.
	 * @param fileName the name of the file to open.
	 * @throws IOException if the program cannot open the given file.
	 */
	public void openFile(String fileName, String title) throws IOException;
	
	/**
	 * Starts a new table with the given title and number of columns.  If a table is already open,
	 * the old table will be completed (using completeRow()) and a new table will be started.
	 * @param title The title of the new table
	 * @param cols The number of columns in the given table
	 * @throws IOException if no file is open.
	 */
	public void startTable(String title, int cols) throws IOException;
	
	/**
	 * Adds a cell to the table.  The text in the cell will be the result of o.toString()
	 * @param o the Object to add to the table.
	 * @throws IOException if no table is open.
	 */
	public void addCell(Object o) throws IOException;
	
	public void addParagraph(String s, boolean isHeader) throws IOException;
	
	/**
	 * Fills any remaining cells in the given row with empty cells.  This can be called manually,
	 * but it is also called when calling startTable() and print().
	 * @throws IOException if no table is open.
	 */
	public void completeRow() throws IOException;
	
	/**
	 * Prints the table to the file which was opened previously.  This ends the table and closes
	 * any streams that are open, as well as closing any open file.
	 * @throws IOException if a problem occurred closing the file or any output streams
	 */
	public void print() throws IOException;
	
	
}
